package OnlineLibrary.managers;

import org.omg.CosNaming.NameComponent;

import Common.Customer;
import ParcelDelivery.DeliveryMgr_Iface.DeliveryMgrHelper;

/**
 * Manages the book delivery
 * @author Loup
 *
 */
public class DeliveryMgr extends Mgr{
	private ParcelDelivery.DeliveryMgr_Iface.DeliveryMgr delivery;

	public DeliveryMgr() {
		super();
		NameComponent[] name = new NameComponent[] { new NameComponent(
				"Delivery", "Object") };
		try {
			//retrive the parcel delivery servant
			delivery = DeliveryMgrHelper.narrow(context
					.resolve(name));
		} catch (Exception e) {
			System.out.println("null");
			delivery = null;
		}
	}
	
	/**
	 * 
	 * @param isbn book isbn to deliver
	 * @param cust customer who buys the book
	 * @return true if the delivery is completed, otherwise false.
	 */
	public boolean newDelivery(String isbn, Customer cust, String BSId){
		return delivery.registerDelivery(isbn, cust, BSId);
	}

}
